<?php defined('SYSPATH') or die('No direct script access.');

class Helper_Date{
	
	public static function dateToMysql($date){
		//como $date es un string debo pasarlo a fecha/tiempo con la funcion
		//strtotime
		return date("Y-m-d",strtotime($date));
	}
	
	public static function mysqlToDate($date){
		return date("d-m-Y",strtotime($date));
	}
	
	public static function determineAge($date){
		
		list($year,$month,$day) = explode("-",$date);
		$year_diff = date("Y") - $year;
		$month_diff = date("m") - $month;
		$day_diff = date("d") - $day;
		
		if ($day_diff < 0 && $month_diff <= 0) $year_diff-–;
		
		return $year_diff;
		
	}
	
	public static function now(){
		return DB::expr('NOW()');
	}
	
	public static function currentDate(){
		return date("d-m-Y");
	}
	
	public static function datediff($start, $end){
		
	}
	
}
